

di "************************************************************************************************************"
di "***************************************LOAD AND LABEL WORKER DATA*******************************************"
di "************************************************************************************************************"

use  "$saveddata/$workerdataname", clear		


noi di "**********************************Sample restrictions**************************************************************" 

drop if birth_ent > 2008


noi di "**********************************Variable generation **************************************************************" 

*Define skilled workers - using 2010 SOC codes
gen skilled10 = 0 if !missing(skill10_ashe)
replace skilled10 = 1 if skill10_ashe == 3 | skill10_ashe == 4

*Generate gender interactions
foreach var of varlist age_ashe tenure_ashe tenure_ashe_sq skilled10{
	gen `var'_sex = `var' * sex_ashe
}


noi di "**********************************Label variables **************************************************************" 

label var ruref 				"Firm-level identifier (numeric)"
label var luref					"Local-unit level identifier (numeric)"
label var piden					"Employee identifier (numeric)"
label var year 					"Year"

label var birth_ent 			"Year enterprise started operations (from BSD)"
label var age_ent				"Enterprise age = year - birth_ent (from BSD)"
label var ln_age_ent			"Log (1 + age_ent) (from BSD)"
label var multiplant			"Dummy = 1 if enterprise has multiple (live) local units at time t (from BSD)"
label var fgn_ent				"Dummy = 1 if ultimate foreign owner of the enterprise is outside the UK (from BSD)"
label var ees_ent 				"Enterprise employees (from BSD)"
label var ees_ent_p95			"95th percentile enterprise employment (from BSD)"
label var ln_ees_ent 			"Log enterprise employees (from BSD)"
label var ln_ees_ent_08			"Log enterprise employees in 2008 (from BSD)"	

label var age_ashe				"Employee age (from ASHE)"
label var tenure_ashe			"Employee tenure (from ASHE)"
label var tenure_ashe_sq		"Employee tenure squared (from ASHE)"   
label var skilled10				"Skilled worker using 2010 SOC codes (from ASHE)"   
label var sex_ashe				"Female worker (from ASHE)"   
label var age_ashe_sex			"= age_ashe * sex_ashe"   
label var tenure_ashe_sex		"= tenure_ashe * sex_ashe"   
label var tenure_ashe_sq_sex	"= tenure_ashe_sq * sex_ashe"   
label var skilled10_sex			"= skilled10 * sex_ashe"   

label var lu_change_D1_ashe		"Dummy = 1 if employee switches to another local unit between t and t+1 (from ASHE)"
label var dist_lu				"Distance of employee's local-unit from enterprise/HQ (km) (from ASHE & BSD)"
label var gr1_dist_lu			"1 period ahead change in distance of employee locaiton from enterprise/HQ = F1.dist_lu - dist_lu"
label var hq_D1_ashe			"Dummy = 1 if employee switches to or from enterprise/HQ between t and t+1 (from ASHE)"

label var fibre_L1				"Dummy = 1 if enterprise's exchange is fiber enabled at time t-1 (from OFCOM)"
label var fibre_enable_year_ent	"Enterprise's fiber enablement year (from OFCOM)"
label var fibre_L1_sizew		"Fiber enablement interacted with enterprise size= fibre_L1 * ln_ees_ent_08"
label var cloud					"Dummy = 1 if firm uses any type of cloud (assume = 0 in 2008) (from Ecommerce)"

label var fibre_enable_year_lu	"Local unit's fiber enablement year (from OFCOM)"
label var pfibre_L1				"Dummy = 1 if local unit's exchange is fiber enabled at time t-1 (from OFCOM)"
label var pcloud				"Dummy = 1 if firm has cloud and local unit has fiber = cloud * pfibre_L1"
label var fibre_L1_sizew		"Fiber enablement interacted with esize= fibre_L1 * ln_ees_ent_08"
label var pfibre_fibre_L1		"Dummy = 1 if both local unit and enterprise have fiber = pfibre_L1 * fibre_L1"
label var pfibre_fibre_L1_sizew	"Fiber enablement interacted with enterprise size = pfibre_fibre_L1 * ln_ees_ent_08"







noi di "**********************************Save data **************************************************************" 

compress
save  "$saveddata/RESTAT_replication_workerdata.dta", replace		



